﻿///*
// * SRSTransformCache
// * 
// * initial implementation : 20.10.2008
// *
// * Copyright (c) Adam Sida, asida@centrum.cz.
// * All rights reserved.
// * 
// * for license see Petra.Gis.License.txt
// */
//using System;
//using System.Collections.Generic;
//using Petra.Gis.ReferenceSystemServices;
//using Petra.Gis.ReferenceSystemServices.Transformations;

//namespace Petra.Gis
//{
//  /// <summary>
//  /// local cache for used transformations, that avoids lookup into main transform storage
//  /// cache saves time necessary to search transform
//  /// </summary>
//  public class SRSTransformPool
//  {

//    //protected MapBase _map;
//    protected TransformList _cache;


//    public SRSTransformPool()
//    {
//      _cache = new TransformList();
//    }





//    //public SRSTransformPool(MapBase map)
//    //  : this()
//    //{
//    //  _map = map;
//    //}




//    public void Clear()
//    {
//      _cache = new TransformList();
//    }




//    /// <summary>
//    /// search for transform from supplied coordinate systems
//    /// Search starts in this local cache,
//    /// if no sutable transform found locally, creates new by searching complete transform db
//    /// if forward only transform requested then forward only is stored to local cache
//    /// if inverse requester both forward and reverse is stored ;-)
//    /// </summary>
//    /// <param name="sourceCS">source coordinate system</param>
//    /// <param name="targetCS">target coordinate system</param>
//    /// <param name="getInverseTransform">flag if transform is requested as inverse</param>
//    /// <returns>prepared coordinate transform, and this transform is also stored in cache</returns>
//    public SRSTransform GetTransform(CoordinateSystem sourceCS, CoordinateSystem targetCS, bool getInverseTransform)
//    {

//      // first look into local map cache for exactly same CS..
//      // including inverse check
//      foreach (SRSTransform t in _cache)
//        if (t.Source.EqualParams(sourceCS, CsCompareType.CompareAllParams) &&
//            t.Target.EqualParams(targetCS, CsCompareType.CompareAllParams) &&
//            t.IsInverse == getInverseTransform)
//          return t;

//      // ok, not found ? create new transform
//      // this call will throw error if no transform found
//      SRSTransform tmp = SRSTransform.GetTransformation(sourceCS, targetCS);
//      _cache.Add(tmp);

//      //if inverse is requested get also inverse version...
//      if (getInverseTransform)
//      {
//        if (tmp.IsInversible)
//          tmp = tmp.Inverse();
//        else
//          tmp = SRSTransform.GetTransformation(targetCS, sourceCS);

//        _cache.Add(tmp);
//      }

//      return tmp;

//    }

//  }
//}
